package com.ewzj.bigdata.app.config;

import android.content.Context;
import android.support.multidex.MultiDex;

import com.tencent.tinker.loader.app.ApplicationLike;
import com.tinkerpatch.sdk.TinkerPatch;
import com.tinkerpatch.sdk.loader.TinkerPatchApplicationLike;

/**
 * author:zhangjing
 * 作用:
 * return:
 */

public class BaseApplication extends com.jess.arms.base.BaseApplication{
    private ApplicationLike tinkerApplicationLike;
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
            /*
                *
                * 热更新初始化
                * */

        // 我们可以从这里获得Tinker加载过程的信息
         tinkerApplicationLike = TinkerPatchApplicationLike.getTinkerPatchApplicationLike();

        // 初始化TinkerPatch SDK, 更多配置可参照API章节中的,初始化SDK
        TinkerPatch.init(tinkerApplicationLike)
                .reflectPatchLibrary()
                .setPatchRollbackOnScreenOff(true)
                .setPatchRestartOnSrceenOff(true)
                .fetchPatchUpdate(false)
                .setPatchRestartOnSrceenOff(true)
                .fetchPatchUpdate(true)
                .setFetchPatchIntervalByHours(5);
        // 每隔3个小时(通过setFetchPatchIntervalByHours设置)去访问后台时候有更新,通过handler实现轮训的效果
//        TinkerPatch.with().fetchPatchUpdateAndPollWithInterval();
    }
}
